/**
 * bibivipRecord管理初始化
 */
var BibivipRecord = {
    id: "BibivipRecordTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
BibivipRecord.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '订单号', field: 'recordId', visible: true, align: 'center', valign: 'middle'},
            {title: '用户id', field: 'userid', visible: true, align: 'center', valign: 'middle'},
            {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle'},
            {title: '生风筝身份证号', field: 'idcard', visible: true, align: 'center', valign: 'middle'},
            {title: '护照', field: 'passport', visible: true, align: 'center', valign: 'middle'},
            {title: '手机号', field: 'phone', visible: true, align: 'center', valign: 'middle'},
            {title: '支付时通证汇率', field: 'rate', visible: true, align: 'center', valign: 'middle'},
            {title: '平台收款账号', field: 'platformAccount', visible: true, align: 'center', valign: 'middle'},
            {title: '创建时间', field: 'creteTime', visible: true, align: 'center', valign: 'middle'},
            {title: '支付时间', field: 'payTime', visible: true, align: 'center', valign: 'middle'},
            {title: '订单状态，1，等待支付，2已支付', field: 'status', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
BibivipRecord.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        BibivipRecord.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加bibivipRecord
 */
BibivipRecord.openAddBibivipRecord = function () {
    var index = layer.open({
        type: 2,
        title: '添加bibivipRecord',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/bibivipRecord/bibivipRecord_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看bibivipRecord详情
 */
BibivipRecord.openBibivipRecordDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: 'bibivipRecord详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/bibivipRecord/bibivipRecord_update/' + BibivipRecord.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除bibivipRecord
 */
BibivipRecord.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/bibivipRecord/delete", function (data) {
            Feng.success("删除成功!");
            BibivipRecord.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("bibivipRecordId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询bibivipRecord列表
 */
BibivipRecord.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    BibivipRecord.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = BibivipRecord.initColumn();
    var table = new BSTable(BibivipRecord.id, "/bibivipRecord/list", defaultColunms);
    table.setPaginationType("client");
    BibivipRecord.table = table.init();
});
